const { DataTypes, Model, Deferrable } = require("sequelize");
const sequelize = require("../../db/sequelize");
/**
 * 商品滚动巨幕模型
 */
class GoodsBanner extends Model {
    static async addBanner(goods_id,banners){
        let json=[]
        await banners.forEach(async value => {
            await this.create({
                goods_id:goods_id,
                banners:value
            }).then(value=>{
                json.push(value.toJSON())
            })
        });
        return json
    }
};
GoodsBanner.init({
    id:{
        type:DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    goods_id:{
        type:DataTypes.INTEGER
    },
    url:{
        type:DataTypes.STRING
    }
}, {
    sequelize,
    modelName: "GoodsBanner",
    tableName: "goods_banner",
    createdAt:"create_time",
    updatedAt:"update_time",
})
module.exports = GoodsBanner